package cn.hanyx.coder.design.pattern.creational.singleton;

import java.util.Calendar;
import java.util.concurrent.atomic.AtomicLong;

/**
 * IdGeneratorEnum
 *
 * @author hanyx
 * @date 2020/05/13
 */
public enum IdGeneratorEnum {
    INSTANCE;
    private AtomicLong id = new AtomicLong(0);

    public long getId() {
        return id.incrementAndGet();
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.out.println(IdGeneratorEnum.INSTANCE.getId());
        }
        Calendar c = Calendar.getInstance();
    }
}
